package annotation;

import java.lang.reflect.Method;

public class ReflectAnnotationTest {
    public static void main(String[] args) {
        try {
            Class c=Class.forName("annotation.annotationTest01");
            //判断类上面是否有@myAnnotation
            boolean b = c.isAnnotationPresent(myAnnotation2.class);
            if(b){
                //获取注解
                myAnnotation2 m=(myAnnotation2)c.getAnnotation(myAnnotation2.class);
                //获取注解对象的属性
                System.out.println(m.value());
            }
            //获取方法上的注解
            Method dos=c.getDeclaredMethod("m1");
            System.out.println(dos.isAnnotationPresent(myAnnotation2.class));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
